package initializers;

import controllers.ChatController; 
import java.util.logging.Level;
import java.util.logging.Logger;
import models.Contact;
import views.ChatGui; 
import views.ChatNi; 

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.B2B321E4-163A-B945-C4AA-E51258B960EA]
// </editor-fold> 
public class ChatSystem {

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.8E6893F2-56D5-9D28-9DF4-6D75564B656F]
    // </editor-fold> 
    private ChatGui gui;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.08703E7D-F672-427D-5C30-2E8E89BA6A30]
    // </editor-fold> 
    private ChatNi ni;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.5AA8B340-A05A-5E31-C6A7-C8D6DD7754A5]
    // </editor-fold> 
    private ChatController cont;

    public ChatSystem() {
        initialize();
    }


    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.BEF67AB8-FEA8-70E2-3E50-4E83EC06C7F5]
    // </editor-fold> 
    public void performExitApp () {
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.7DD2620F-35FA-64E9-80FD-A55E08003831]
    // </editor-fold>
    /**
     * Méthode initialize, permet d'initialiser le système:
     * Création des composants et des liens entre eux
     */
    public void initialize () {
        /* Création des composants */
        gui = new ChatGui();
        //ni = new ChatNi();
        cont = new ChatController();

        /* Liens entre les composants */
        cont.setChatSystem(this);
        cont.setGui(gui);
        //cont.setNi(ni);
        gui.setController(cont);
        //ni.setController(cont);
        new Thread(gui).start();
        
        // Ajouter 3 contacts dans la liste
        try {
            Thread.currentThread().sleep(3000);
        } catch (InterruptedException ex) {
            Logger.getLogger(ChatSystem.class.getName()).log(Level.SEVERE, null, ex);
        }
        cont.newContact(new Contact("long", "son adresse"), false);
        try {
            Thread.currentThread().sleep(3000);
        } catch (InterruptedException ex) {
            Logger.getLogger(ChatSystem.class.getName()).log(Level.SEVERE, null, ex);
        }
        cont.newContact(new Contact("suzanne", "son adresse"), false);
        try {
            Thread.currentThread().sleep(3000);
        } catch (InterruptedException ex) {
            Logger.getLogger(ChatSystem.class.getName()).log(Level.SEVERE, null, ex);
        }
        cont.newContact(new Contact("fatim", "son adresse"), false);  
    }

}

